<template>
	<view>
		<view class="card doctor_item"
			@click="gotoPage(`/pagesCommon/doctor/details?doctorId=${item.doctorSettingVo.doctorId || item.id}&consultWay=${fromPage}`)">
			<view class="doctor_info">
				<view class="info_text">
					<view class="doctor_info_self">
						<view class="text_name">
							{{item.name || ''}}
						</view>
						<view>
							{{item.titleName || ''}}
						</view>
						<view>
							{{item.departName || ''}}
						</view>
					</view>
					<view class="doctor_info_hospitoal">
						<view class="info_tips green">
							{{item.levelName || ''}}
						</view>
						<view>
							{{item.hospitalName || ''}}
						</view>
					</view>
				</view>
				<view class="info_avatar">
					<image
						:src="item.avatar || 'https://www.qidujiangtaigong.com/api//admin-api/infra/file/0/get/2b4e1a3e542b87133e8a689fe126555e9d906a511bfdcde36a0192d84c79ea80.jpg'"
						mode="aspectFill"></image>
				</view>
			</view>
			<view class="doctor_evaluate">
				<view class="evaluate star">
					<view class="icon">
						<image src="@/static/icon/doctor/star-icon.png" mode="widthFix"></image>
					</view>
					<view class="nums">
						{{item.favorableCount || 0}}%
					</view>
				</view>
				<view class="evaluate">
					<view class="icon">
						接诊量
					</view>
					<view class="nums">
						{{item.treatmentCount || 0}}
					</view>
				</view>
				<view class="evaluate">
					<view class="icon">
						回复
					</view>
					<view class="nums">
						{{item.replySpeed || ''}}
					</view>
				</view>
			</view>
			<view class="doctor_capacity ellipsis-2">
				<text class="text">擅长:</text>
				{{item.proficient || ''}}
			</view>
			<view class="doctor_contact">
				<view class="contact_item" v-if="startService(item,'Text')" @click.stop="gotoManagementList(item,'Text')">
					<view class="item_icon">
						<image src="@/static/icon/doctor/online-icon.png" mode="widthFix"></image>
					</view>
					<view class="item_text">
						<text class="text">图文</text>
						<text class="nums">￥{{totalPrice(item,'Text')}}</text>
					</view>
				</view>
				<view class="contact_item" v-if="startService(item,'Speech')" @click.stop="gotoManagementList(item,'Speech')">
					<view class="item_icon">
						<image src="@/static/icon/doctor/phone-icon.png" mode="widthFix"></image>
					</view>
					<view class="item_text">
						<text class="text">语音</text>
						<text class="nums">￥{{totalPrice(item,'Speech')}}</text>
					</view>
				</view>
				<view class="contact_item" v-if="startService(item,'Video')" @click.stop="gotoManagementList(item,'Video')">
					<view class="item_icon line_height">
						<image src="@/static/icon/doctor/video-icon.png" mode="widthFix"></image>
					</view>
					<view class="item_text">
						<text class="text">视频</text>
						<text class="nums">￥{{totalPrice(item,'Video')}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "doctorChatItem",
		props: {
			item: {
				type: [Object, String],
				default: () => {
					return {}
				}
			},
			fromPage: {
				type: [Number, String],
				default: 1
			}
		},
		data() {
			return {

			};
		},
		components: {

		},
		methods: {
			startService(item, type) {
				let way = this.fromPage == 1 ? 'ordinary' : 'expert'
				return item.doctorSettingVo && item.doctorSettingVo[`${way}${type}`] == 1 ? true : false
			},
			totalPrice(item, type) {
				let way = this.fromPage == 1 ? 'ordinary' : 'expert'
				switch (type) {
					case 'Text':
						// return item.doctorSettingVo[`${way}${type}Amount`] || null + item.doctorSettingVo['pictureTextAmount']
						return item.doctorSettingVo && item.doctorSettingVo[`${way}${type}Amount`] || 0
						break;
					case 'Speech':
						// return item.doctorSettingVo[`${way}${type}Amount`] || null + item.doctorSettingVo['speechPlatform']
						return item.doctorSettingVo && item.doctorSettingVo[`${way}${type}Amount`] || 0
						break;
					case 'Video':
						// return item.doctorSettingVo[`${way}${type}Amount`] || null + item.doctorSettingVo['videoPlatform']
						
						return item.doctorSettingVo && item.doctorSettingVo[`${way}${type}Amount`] || 0
						break;
					default:
						break;
				}
			},
			gotoPage(url) {
				uni.navigateTo({
					url
				})
			},
			gotoManagementList(item, type) {
				let consultationAmount = this.totalPrice(item, type)
				let consultationMethod = type == 'Text' ? 1 : type == 'Speech' ? 2 : type == 'Video' ? 3 : 0
				let outpatientInfoCreate = {
					doctorId: item.id,
					consultationSource: this.fromPage,
					consultationMethod: consultationMethod,
					consultationAmount: consultationAmount,
					titleId: item.titleId,
					departId: item.departId
				}
				uni.navigateTo({
					url: `/pagesCommon/patient/managementList?outpatientInfoCreate=${JSON.stringify(outpatientInfoCreate)}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.doctor_item {
		margin-bottom: 30rpx;

		.doctor_info {
			font-size: 24rpx;
			color: #666666;
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 10rpx;

			.info_text {

				.doctor_info_self,
				.doctor_info_hospitoal {
					display: flex;
					align-items: flex-end;
					margin-bottom: 20rpx;

					&>view {
						margin-right: 20rpx;
					}
				}

				.doctor_info_hospitoal {
					align-items: center;
					font-size: 26rpx;
				}

				.text_name {
					font-weight: bold;
					font-size: 32rpx;
					color: #333333;
				}

				.info_tips {
					padding: 6rpx 10rpx;
					border-radius: 10rpx;
					font-size: 22rpx;

					&.green {
						color: #23CC88;
						background-color: #DEF7ED;
					}

					&.yellow {
						color: #F1AE34;
						background-color: #FDF3E1;
					}
				}
			}

			.info_avatar {
				width: 90rpx;
				height: 90rpx;
				border-radius: 100%;
				overflow: hidden;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}

		.doctor_evaluate {
			display: flex;
			align-items: center;
			margin: 30rpx 0;

			.evaluate {
				margin-right: 20rpx;
				display: flex;
				align-items: center;

				&.star {
					.nums {
						font-weight: bold;
						font-size: 26rpx;
						color: #F1AE34;
					}
				}

				.icon {
					margin-right: 10rpx;
					font-size: 22rpx;
					color: rgba(153, 153, 153, 0.8);

					image {
						width: 26rpx;
						height: 26rpx;
					}
				}

				.nums {
					font-weight: bold;
					font-size: 26rpx;
					color: #333333;
				}
			}
		}

		.doctor_capacity {
			margin-bottom: 30rpx;
			color: #333;
			font-size: 26rpx;

			.text {
				display: inline-block;
				color: #999999;
				margin-right: 10rpx;
			}
		}

		.doctor_contact {
			display: flex;
			align-items: center;

			.contact_item {
				flex: 0 0 32.5%;
				padding: 8rpx 14rpx;
				margin-right: 1%;
				box-sizing: border-box;
				border-radius: 100rpx;
				border: 1px solid #EEEEEE;
				display: flex;
				align-items: center;
				overflow: hidden;

				&:last-child {
					margin: 0;
				}

				.item_icon {
					width: 30rpx;
					height: 30rpx;

					&.line_height {
						margin: 0 auto;
						line-height: 30rpx;
					}

					image {
						width: 100%;
						height: 100%;
					}
				}

				.item_text {
					display: flex;
					align-items: center;
					justify-content: center;

					.text {
						font-size: 24rpx;
						color: #999999;
						margin: 0 10rpx;
					}

					.nums {
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
					}
				}
			}
		}
	}
</style>